<?php


namespace app\api\controller\v1;


use app\api\model\UserChargeModel;
use app\common\controller\UserBaseController;

class UserchargeController extends UserBaseController {

    function submit_wxmpAction() {
        $this->paramlist = [
            'amount' => 'int',
        ];

        $this->check_params();
        $this->check_token();

        $amount = $this->argv['amount'];
        global $g_env;
        if ($g_env != 'ONLINE') {
            $amount = 1;
        }
        $ret = (new UserChargeModel())->submit_wxmp($amount);
        $this->resp['info'] = $ret;

        return $this->ret_resp();
    }

    function listAction() {
        $this->paramlist = [
            'user_id' => 'optstring',
            'pno' => 'optint',
            'psize' => 'optint',
        ];
        $this->check_params();
        $this->check_token();

        $l = (new UserChargeModel())->query_list($this->argv, $this->argv['pos'], $this->argv['limit']);
        $this->resp['list'] = $l;
        $this->resp['total'] = hisql::query_count();


        return $this->ret_resp();
    }

}
